package jnBase.script
{
	import laya.components.Script;
	import laya.events.Event;
	import laya.media.SoundManager;
	import laya.ui.Button;
	import laya.utils.Tween;
	
	public class ScaleButton extends Script
	{
		public var soundUrl:String;
		public function ScaleButton()
		{
			super();
		}
		
		override public function onAwake():void
		{
			// TODO Auto Generated method stub
			super.onAwake();
			(owner as Button).anchorX=0.5;
			(owner as Button).anchorY=0.5;
		}
		
		override public function onMouseDown(e:Event):void
		{
			// TODO Auto Generated method stub
			super.onClick(e);
			Tween.clearAll(owner);
			(owner as Button).scale(1,1);
			Tween.to(owner,{scaleX:0.8,scaleY:0.8},100);
			if(soundUrl){
				SoundManager.playSound(soundUrl);
			}
		}
		
		override public function onStageMouseUp(e:Event):void
		{
			// TODO Auto Generated method stub
			super.onStageMouseUp(e);
			Tween.clearAll(owner);
			(owner as Button).scale(1,1);
			Tween.to(owner,{scaleX:1,scaleY:1},30);
		}
		
		
		override public function onMouseUp(e:Event):void
		{
			// TODO Auto Generated method stub
			super.onMouseUp(e);
			Tween.clearAll(owner);
//			(owner as Button).scale(1,1);
			Tween.to(owner,{scaleX:1,scaleY:1},30);
		}
		
		
	}
}